import { defineStore } from "pinia"

import { insertTest } from "@/api/login"

interface ItestState {
  username: string
  date: string
  answer: string
}

export const useTestStore = defineStore({
  id: "test",
  state: (): ItestState => {
    return {
      username: "",
      date: "",
      answer: ""
    }
  },
  actions: {
    getTest(testInfo: { username: string; date: string; answer: string }) {
      return new Promise(() => {
        insertTest({
          username: testInfo.username,
          date: testInfo.date,
          answer: testInfo.answer
        })
      })
    }
  }
})
